<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>渲染数组</title>
</head>
<body>
<ul>
    <li data-for="['durant', 'kobe', 'james', 'curry']"></li>
</ul>

<script>
    let element = document.querySelector("ul > li");
    // console.log(element);

    let parent = element.parentElement;
    parent.removeChild(element)
    if (element.hasAttribute("data-for")) {
        let attribute = element.getAttribute("data-for");
        let array = eval(attribute);
        console.log(array);

        for (let i = 0; i < array.length; i++) {
            let htmlElement = document.createElement(element.tagName);
            htmlElement.textContent = array[i]
            parent.appendChild(htmlElement)
        }
    }
</script>
</body>
</html>